{% extends "catalog/base_generic.html" %}

{% block content %}
<div class="row justify-content-center">
    <div class="col-md-6">
        <div class="card">
            <div class="card-body">
                <h3 class="card-title text-center mb-4">
                    <i class="fas fa-sign-in-alt me-2"></i>用户登录
                </h3>

                {% if form.errors %}
                <div class="alert alert-danger">
                    <i class="fas fa-exclamation-circle me-2"></i>用户名或密码不正确，请重试。
                </div>
                {% endif %}

                {% if next %}
                    {% if user.is_authenticated %}
                    <div class="alert alert-warning">
                        <i class="fas fa-exclamation-triangle me-2"></i>您没有访问该页面的权限。
                    </div>
                    {% else %}
                    <div class="alert alert-info">
                        <i class="fas fa-info-circle me-2"></i>请登录后继续。
                    </div>
                    {% endif %}
                {% endif %}

                <form method="post" action="{% url 'login' %}">
                    {% csrf_token %}
                    <div class="mb-3">
                        <label for="username" class="form-label">用户名：</label>
                        <div class="input-group">
                            <span class="input-group-text">
                                <i class="fas fa-user"></i>
                            </span>
                            <input type="text" name="username" id="username" class="form-control" placeholder="请输入用户名">
                        </div>
                    </div>
                    <div class="mb-3">
                        <label for="password" class="form-label">密码：</label>
                        <div class="input-group">
                            <span class="input-group-text">
                                <i class="fas fa-lock"></i>
                            </span>
                            <input type="password" name="password" id="password" class="form-control" placeholder="请输入密码">
                        </div>
                    </div>
                    <div class="d-grid gap-2">
                        <button type="submit" class="btn btn-primary">
                            <i class="fas fa-sign-in-alt me-2"></i>登录
                        </button>
                    </div>
                    <input type="hidden" name="next" value="{{ next }}">
                </form>

                <div class="mt-3 text-center">
                    <p class="mb-0">
                        <a href="{% url 'password_reset' %}" class="text-decoration-none">
                            <i class="fas fa-key me-1"></i>忘记密码？
                        </a>
                    </p>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 